{% extends 'myhome/index.html' %}
{% block title %}
<title>天天生鲜-登录</title>
{% endblock %}
{% block main %}
{%  block shop %}
{% endblock %}
<body>
	<div class="login_top clearfix">
		<a href="{% url 'myhome_index' %}" class="login_logo"><img src="/static/myhome/images/logo02.png"></a>	
	</div>
	<div class="login_form_bg">
		<div class="login_form_wrap clearfix">
			<div class="login_banner fl"></div>
			<div class="slogan fl">日夜兼程 · 急速送达</div>
			<div class="login_form fr">
				<div class="login_title clearfix">
					<h1>用户登录</h1>
					<a href="{% url 'myhome_register' %}">立即注册</a>
				</div>
				<div class="form_input">
					<form method="post" action="{% url 'myhome_login' %}">
					{% csrf_token %}
						<input type="text" name="phone" class="name_input" placeholder="请输入手机号" >
						<div class="user_error">输入错误</div>
						<input type="password" name="password" class="pass_input" placeholder="请输入密码">
						<div class="pwd_error">输入错误</div>
						<div class="more_input clearfix">
							<input type="checkbox" name="">
							<label>记住用户名</label>
							<a href="#">忘记密码</a>
						</div>
						<input type="submit" name="" value="登录" class="input_submit">
					</form>
				</div>
			</div>
		</div>
	</div>
	<script type="text/javascript">
	$(".name_input").blur(function(){
		phones()
	})
	pflag = false
	pwdflag = false
	function phones(){
		// 验证手机号
		var vals = $('.name_input').val();
		var reg = /^1[345678]\d{9}$/
		
		if(reg.test(vals)==false){
			$('.user_error').css("color","red").html('请输入正确的手机号码格式')
			$('.user_error').show();
			pflag = false
		}else{
			$('.user_error').hide();
			pflag = true
		}
	}
	function pwd(){
		if($(".pass_input").val().length<6){
			$('.pwd_error').css("color","red").html('密码最少6为。最多20为')
			$('.pwd_error').show();
			pwdflag = false
		}else{
			$('.pwd_error').hide();
			pwdflag = true
		}
	}
	$(".input_submit").click(function(){
		phones()
		pwd()
		if(pflag && pwdflag){
			return true
		}else{
			return false
		}
	})
	</script>
{% endblock %}